package chess;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.JLabel;
import javax.swing.JPanel;

import chessman.Chessman;


public class ImagePanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6631404448587217281L;
	private Image image;
	private Chessman chessman;
	private int indexPosition;

	public int getIndexPosition() {
		return indexPosition;
	}

	public void setIndexPosition(int indexPosition) {
		this.indexPosition = indexPosition;
	}

	/**
	 * Default constructor used to set the image for the background for the
	 * instance
	 */
	public ImagePanel(Image img) {
		image = img;
		chessman = null;

	}

	public Chessman getChessman() {
		return chessman;
	}

	public void setChessman(Chessman chessman) {
		this.chessman = chessman;
	}

	public String getStringPosition() {
		JLabel targetLabel = (JLabel) this.getComponent(1);
		return targetLabel.getName();
	}

	@Override
	protected void paintComponent(Graphics g) {
		// draws image to background to scale of frame
		g.drawImage(image, 0, 0, null);
	}
}
